package com.xiaoshuidi.cloud.module.member.controller.admin.coupon.vo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.xiaoshuidi.cloud.module.member.enums.coupon.CouponTypeEnum;
import com.xiaoshuidi.cloud.module.member.enums.coupon.CouponUsageStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author Ivan.Wu
 * @description 优惠券明细
 * @date 2023/3/20 15:33
 */
@Data
public class CouponDetailedVo {

    @Schema(description = "用户优惠券id")
    private Long customerCouponId;

    @ExcelProperty("优惠码")
    @Schema(description = "优惠券券码")
    private String couponCode;

    @ExcelProperty("优惠名称")
    @Schema(description = "优惠名称")
    private String couponName;

    private Integer couponType;

    @ExcelProperty("优惠类型")
    @Schema(description = "优惠类型")
    private String couponTypeDesc;

    @ExcelProperty("发放账户")
    @Schema(description = "发放账户")
    private String userPhone;

    @Schema(description = "租客昵称")
    private String nickName;

    @ExcelProperty("账单编号")
    @Schema(description = "账单编号")
    private String relevanceBill;

    @ExcelProperty("发券时间")
    @Schema(description = "发券时间")
    private Date createTime;

    @Schema(description = "有效时间")
    private Date startTime;

    @Schema(description = "有效时间")
    private Date endTime;

    @ExcelProperty("使用时间")
    @Schema(description = "使用时间")
    private Date usageTime;

    private Integer usageStatus;

    @ExcelProperty("优惠券状态")
    @Schema(description = "使用状态")
    private String usageStatusDesc;

    @ExcelProperty("优惠金额")
    @Schema(description = "优惠金额")
    private BigDecimal preferentialAmount;

    @ExcelProperty("发券人")
    @Schema(description = "发券人")
    private String issuerName;

    @ExcelProperty("用券时间")
    private String effectiveTime;

    @ExcelIgnore
    private String billNo;

    public String getCouponTypeDesc() {
        return CouponTypeEnum.getDesc(couponType);
    }

    public String getUsageStatusDesc() {
        return CouponUsageStatusEnum.getDesc(usageStatus);
    }

    public String getEffectiveTime() {
        return DateFormatUtils.format(startTime, "yyyy-MM-dd") + " ~ " + DateFormatUtils.format(endTime, "yyyy-MM-dd");
    }
}
